﻿using Sidvall.UI.Entities;
using System.Threading.Tasks;

namespace Sidvall.UI.Uwp.Test.ViewModels
{
    public sealed class MainWindowViewModel : Sidvall.UI.ViewModels.MainWindowViewModelBase
    {
        #region Public Members

        #region Title

        private string _Title;
        public string Title
        {
            get
            {
                return _Title;
            }
            set
            {
                if (_Title == value)
                    return;
                _Title = value;
                RaisePropertyChanged(nameof(Title));
            }
        }

        #endregion
        #region MenuItems

        private MenuItemCollection _MenuItems;
        public MenuItemCollection MenuItems
        {
            get
            {
                return _MenuItems;
            }
            private set
            {
                _MenuItems = value;
                RaisePropertyChanged(nameof(MenuItems));
            }
        }

        #endregion
        #region OptionItems

        private MenuItemCollection _OptionItems;
        public MenuItemCollection OptionItems
        {
            get
            {
                return _OptionItems;
            }
            private set
            {
                _OptionItems = value;
                RaisePropertyChanged(nameof(OptionItems));
            }
        }

        #endregion

        #region SelectMenuItemAsync

        public Task SelectMenuItemAsync(string id)
        {
            switch (id)
            {
                case "1":
                    ShowViewModel<Page1ViewModel>((object)null, false, "CenterContent");
                    break;
                case "2":
                    ShowViewModel<Page2ViewModel>((object)null, false, "CenterContent");
                    break;
                default:
                    break;
            }
            return Task.FromResult(true);
        }

        #endregion
        #region SelectOptionItemAsync

        public Task SelectOptionItemAsync(string id)
        {
            switch (id)
            {
                case "1":
                    ShowViewModel<Page1ViewModel>((object)null, false, "CenterContent");
                    break;
                case "2":
                    ShowViewModel<Page2ViewModel>((object)null, false, "CenterContent");
                    break;
                default:
                    break;
            }
            return Task.FromResult(true);
        }

        #endregion

        #region Start

        public void Start(string title)
        {
            Start();

            this.Title = title;
            var menuItems = new MenuItemCollection();
            menuItems.Add("1", "", "Page 1", "", "Home", "", null);
            menuItems.Add("2", "", "Page 2", "", "", "", null);
            this.MenuItems = menuItems;

            var optionItems = new MenuItemCollection();
            optionItems.Add("1", "", "Log on", "", "User-Add", "", null);
            optionItems.Add("2", "", "Settings", "", "Settings", "", null);
            this.OptionItems = optionItems;
        }

        #endregion

        #endregion
        #region Constructors

        public MainWindowViewModel()
        {
        }

        #endregion
    }
}
